package com.gengdan.service.impl;


import com.gengdan.bean.UserLoginBean;
import com.gengdan.dao.UserLoginDao;
import com.gengdan.service.EmailRelatedService;
import com.gengdan.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class UserLoginServiceImpl implements UserLoginService {

    @Autowired
    private UserLoginDao userLoginDao;

    @Autowired
    private EmailRelatedService emailRelatedService;

    @Autowired
    private HashMap<String,Object> hm;

    @Override
    public HashMap getUserLoginByLoginName(String loginName) {

        List<UserLoginBean> userLoginBean = userLoginDao.getUserLoginByLoginName(loginName);

        if(loginName==""){
            hm.put("status","0");
            hm.put("msg","用户名为空");
            hm.put("table_user_login_data",userLoginBean);
            return hm;
        }

        if(userLoginBean.isEmpty()){
            hm.put("status","1");
            hm.put("msg","该用户不存在");
            hm.put("table_user_login_data",userLoginBean);
            return hm;
        }

        hm.put("status","2");
        hm.put("msg","用户已读取");
        hm.put("table_user_login_data",userLoginBean);

        return hm;
    }

    @Override
    public HashMap reportEmailStatus(String loginName) {

        List<UserLoginBean> userLoginBeanList = userLoginDao.getUserLoginByLoginName(loginName);

        if (userLoginBeanList.isEmpty()){
            hm.put("status","0");
            hm.put("msg","该用户不存在");
            return hm;
        }

        UserLoginBean  userLoginBean = userLoginBeanList.get(0);

        return emailRelatedService.getReport(userLoginBean);
    }

    @Override
    public HashMap reportResetStatus(String loginName, String token) {

        List<UserLoginBean> userLoginBeanList = userLoginDao.getUserLoginByLoginName(loginName);


        return null;
    }


}
